package com.bootdo.clouddo.service.book.impl;

import com.bootdo.clouddo.dao.book.BookCatalogueMapper;
import com.bootdo.clouddo.domain.book.BookCatalogue;
import com.bootdo.clouddo.service.book.IBookCatalogueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookCatalogueServiceImpl implements IBookCatalogueService {

    @Autowired
    private BookCatalogueMapper dao;

    @Override
    public int save(BookCatalogue record) {
        if(!dao.exists(record.getBookId(), record.getSiteId(), record.getUrl())){
            return dao.insertSelective(record);
        }
        return 0;
    }

    @Override
    public List<BookCatalogue> findByBook(Long bookId, Integer siteId) {
        return dao.findByBook(bookId, siteId);
    }
}
